<?php
class Ctp_Post_Update_Action extends NICED_Action 
{       
	public function execute() 
	{
		$controller = $this->getController();
		$request    = $controller->getRequest();			

        //load param
        $app     = $request->loadParam("app", 0, "posint");
        $sequence = $request->loadParam("sequence", 0, "posint");
        $title   = $request->loadParam("title", NULL, "safe");
        $body    = $request->loadParam("body", NULL, "safe");
        $post_sequence = $request->loadParam("post_sequence", 0, "posint");

		try
		{
			$model = $controller->getModel('Ctp.Index');
            $thread = $model->getThread($app, $sequence);
            $meta = Ctp_Index_Model::buildMeta(array("title" => $title, "body" => $body));
			$bool  = $model->updatePost($thread, $post_sequence, $meta);
		}
		catch (Exception $e)
		{
			$controller->handleException($e);
			return self::SUCCESS;
		}

		return self::SUCCESS;
	}

}//end class

